#include "../StdInc.h"
#include <boost/algorithm/string.hpp>
#include <boost/regex.hpp>
#include <boost/format.hpp>

using namespace boost;
namespace GSTrader
{
	namespace Option
	{
		CUnderlyingAsset::CUnderlyingAsset()
		{
			m_nQuoteType = 0;
		}

		CUnderlyingAsset::~CUnderlyingAsset()
		{

		}



		COptionInstrument::COptionInstrument()
		{
			m_strType = "";
			m_strMaturityDate = "";
			m_bCallOption = false;
			m_dStrikePrice = 0;
		}


		COptionInstrument::~COptionInstrument()
		{
		}

		bool COptionInstrument::AnalysisFutureOption()
		{
			if (m_strSymbol.empty())
				return false;

			cmatch what;
			regex expression("^(\\D+)(\\d+)(-?)([CP])(-?)(\\d+)");

			if (regex_match(m_strSymbol.c_str(), what, expression))
			{
				size_t nSize = what.size();
				if (nSize == 7)
				{
					m_strType = what[1].str();
					m_strMaturityDate = what[2].str();
					m_bCallOption = what[4].str() == "C";
					m_dStrikePrice = atof(what[6].str().c_str());

					return true;
				}
			}

			return false;
		}

		bool COptionInstrument::AnalysisStockOption()
		{
			return false;
		}
	}
}